package com.serkol.ams.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.serkol.ams.entity.SysConfig;
import com.serkol.ams.mapper.SysConfigMapper;
import com.serkol.ams.service.SysConfigService;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
* @author pingan
* @description 针对表【sys_config】的数据库操作Service实现
* @createDate 2022-09-28 12:32:43
*/
@CacheConfig(cacheNames = "systemConfig")
@Service
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig>
    implements SysConfigService{
    @Cacheable(cacheNames = "systemConfig", key = "'findByKeys'")
    @Override
    public Map<String, Object> findByKeys() {

        Map<String, Object> map = new HashMap<>();
        List<SysConfig> list = this.list();
        Iterator<SysConfig> iterator = list.iterator();
        while (iterator.hasNext()) {
            SysConfig next = iterator.next();
            map.put(next.getIsKey(), next.getIsValue());
        }
        return map;
    }
}




